

<!-- 设置支付密码 -->
<template>
	<view class="container">
		<view class="oneRow" style="margin-top: 20rpx;">
			<view class="list-cell b-b radiusT10">
				<text class="cell-tit">手机号</text>
				<view class="cell-tip">
					{{phoneNumber}}
				</view>
			</view>
			<view class="list-cell radiusB10">
				<text class="cell-tit">验证码</text>
				<input class="cell-tip" type="text" v-model="verifyCode" placeholder-class="inputHolder" placeholder="输入验证码"/>
				<verifyCode :phoneNumber="phoneNumber"></verifyCode>
			</view>
		</view>
		
		<view class="oneRow">
			<view class="list-cell radiusT10">
				<text class="cell-tit">请输入密码</text>
			</view>
			<view @tap="showFun" class="setPass-Container radiusB10">
				<view class="content">
					<view v-for="(item, index) in 6" :key="item" class="password-item borderOneRpx">
						{{password[index] ? '●' :''}}
					</view>
				</view>
			</view>
			<pay-keyboard :show_key="show_key" @hideFun="hideFun" @getPassword="getPassword"></pay-keyboard>
		</view>
		
		
		<!-- 保存 -->
		<view class="oneRow">
			<view class="list-cell save-btn" @click="submit()">
				保存
			</view>
		</view>
	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	
	import payKeyboard from '@/components/keyboard/keyboard'
	import verifyCode from '@/components/verify-code/verify-code'

	export default {
		components:{
			payKeyboard,
			verifyCode
		},
		computed: {
			...mapState(['imgSite', 'hasLogin'])
		},
		data() {
			return {
				icon: {
					backBtn: "/static/images/common/return.png",
					rDefaultBtn: "/static/images/user/userInfo/r_default.png",
					rSelectBtn: "/static/images/user/userInfo/r_select.png",
				},
				show_key: false,
				password: '',
				phoneNumber: "",
				verifyCode: ""
			};
		},
		onLoad(res) {
			this.phoneNumber = res.phone;
			
			if(!this.phoneNumber) {
				
				var that = this;
				that.$api.globalUtil.methodFilter({
					that: that,
					success: function() {
						that.$api.globalUtil.getUserInfo(that, function(res) {
							that.phoneNumber = res.data.response.telephone;
						});
						console.log("成功");
					}
				});
			}
		},
		methods: {
			
			// 支付密码
			showFun(){
				this.show_key = true;
			},
			hideFun(){
				this.show_key = false;
			},
			getPassword(n){
				this.password = n;
			},
			submit(){
				let that = this;
				that.$api.globalUtil.requestAjax({
					url: '/CustomerApi/updatePayPasswordForApi',
					method: 'POST',
					data: {
						password:that.password,
						rePassword:that.password,
						telephone:that.phoneNumber,
						vcode:that.verifyCode
					},
					success: function(res) {
						
						that.$api.msg("支付密码设置成功!");
						
						setTimeout(function() {
							uni.navigateBack({
							});
						}, 1500);
					}
				});
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #F5F5F5;
	}
	
	// header部分
	.header-Container {
		position: relative;
		width: 100%;
		height: 176rpx;
		overflow: hidden;
		box-shadow: 0px 1px 1px 0px rgba(0, 0, 0, 0.08);
		background: rgba(255, 255, 255, 1);
	
		.leftBtns {
			display: flex;
			align-items: center;
			justify-content: flex-start;
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
	
			.back {
				margin-left: 17rpx;
				width: 44rpx;
				height: 44rpx;
			}
		}
	
		.title {
			position: absolute;
			bottom: 0;
			width: 100%;
			height: 86rpx;
			line-height: 86rpx;
			text-align: center;
			font-size: 36rpx;
			font-family: PingFang SC;
			font-weight: bold;
			color: rgba(51, 51, 51, 1);
		}
	}
	
	.container {
		.oneRow {
			margin-top: 20rpx;
			padding: 0 30rpx;
			border-radius: 10rpx;
			
			.radiusT10 {
				border-radius: 10rpx 10rpx 0 0;
			}
			.radiusB10 {
				border-radius: 0 0 10rpx 10rpx;
			}
			
			.verify-Container {
				position: relative;
				
				&.borderOneRpx:after {
					border-color: rgba(210,23,40,1);
					border-radius: 44rpx;
				}
				
				width:140rpx;
				height:44rpx;
				line-height: 44rpx;
				border-radius:22rpx;
				text-align: center;
				font-size:22rpx;
				font-family:PingFang;
				color:rgba(210,23,40,1);
			}
		}
	}
	.list-cell{
		display:flex;
		align-items:center;
		padding: 0 40rpx 0 50rpx;
		height: 104rpx;
		line-height:104rpx;
		position:relative;
		background: #fff;
		// justify-content: flex-start;
		
		input {
			text-align: right;
			color: #333333;
		}
		
		.inputHolder {
			font-size:28rpx;
			font-family:PingFang;
			color:#BFBFBF;
			line-height:55px;
		}
		
		&.save-btn{
			justify-content: center;
			margin: 0 auto;
			margin-top: 140rpx;
			width:600rpx;
			height:90rpx;
			line-height: 90rpx;
			background: #FE5E49;
			border-radius:45rpx;
			text-align: center;
			font-size:34rpx;
			font-family:PingFang;
			color:rgba(255,255,255,1);
		}
		&.cell-hover{
			background:#fafafa;
		}
		&.b-b:after{
			left: 30rpx;
			right: 30rpx;
		}
		&.m-t{
			margin-top: 16upx; 
		}
		.cell-more{
			align-self: baseline;
			font-size:$font-lg;
			color:$font-color-light;
			margin-left:10upx;
		}
		.cell-tit{
			margin-right:10upx;
			font-size:28rpx;
			font-family:PingFang;
			color:#666666;
		}
		.cell-tip{
			flex: 1;
			text-align: left;
			margin-left: 35rpx;
			font-size:28rpx;
			font-family:PingFang;
			color:#333333;
			line-height:55rpx;
			
			&.unBind {
				color: #D21728;
			}
			&.unSet {
				color: #999999;
			}
		}
	}
	
	//设置密码
	.setPass-Container {
		height: 140rpx;
		background-color: #FFFFFF;
		
		.content {
			display: flex;
			align-items: flex-start;
			justify-content: space-between;
			margin: 0 auto;
			width: 590rpx;
			
			.password-item {
				position: relative;
				width: 90rpx;
				height: 90rpx;
				line-height: 90rpx;
				text-align: center;
				font-size:60rpx;
				/* #ifdef MP-WEIXIN */
				font-size: 30rpx;
				/* #endif */
				font-family:PingFang;
				color:#333333;
				
				&.borderOneRpx:after {
					border-width: 4rpx;
					border-color: rgba(238,238,238,1);
					border-radius: 5rpx;
				}
			}
		}
	}
</style>



